<?php

use Illuminate\Database\Seeder;

class UserCoverSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // 营销网页
        $marks = \App\Model\UserMarketing::get();
        foreach ($marks as $mark){
            $contents = json_decode ($mark->contents);
            $con = $contents->content;
            $src = isset($con[0]->src)?$con[0]->src: env ("weixinUrl").'/static/marketing/cover.png';
            $mark->cover = $src;
            $mark->save();
        }

        //个人网页
        $web_sites = \App\Model\PersonalPageTemplateUser::get();
        foreach ($web_sites as $site){
            $contents = json_decode ($site->content);
            foreach ($contents as $content){

                if (isset($content->type)&&$content->type == 'slider') {
                    $cover  = $content->children[0]->img->src;
                    $site->cover = $cover;
                    $site->save();
                }else{
                    $site->cover = env ("weixinUrl").'/static/cover_custom.png';
                    $site->save();
                }
            }
        }

    }
}
